$(function(){
    var id = $("#caseId").val();
    var wedTypeOption = "",wedEnvironmentOption = "";
    var wedType = getDictByType(1);
    var wedEnvironment = getDictByType(2);
    $(wedType).each(function(i,data){
        wedTypeOption += '<option value="' + data.name + '">' + data.name +'</option>'
    });
    $(wedEnvironment).each(function(i,data){
        wedEnvironmentOption += '<option value="' + data.name + '">' + data.name +'</option>'
    });
    $("#caseType").html(wedTypeOption);
    $("#caseEnvironment").html(wedEnvironmentOption);

    if(id){
        $.ajax({
            type : "post",
            url : "htmlWeb/getExamplePageList",//,"payStatus" : -2
            data: {"id" : id},
            async: false,
            success : function(data){
                var str = "";
                $.each(data.rows,function(i,obj){
                    obj = trimEmpty(obj);
                    $("#caseName").val(obj.name);
                    $("#caseTime").val(obj.caseTime);
                    $("#caseHotel").val(obj.caseHotel);
                    $("#caseDetail").val(obj.caseDetail);
                    $("#caseComment").val(obj.caseComment);
                    $("#caseEnvironment").val(obj.caseEnvironment);
                    $("#caseType").val(obj.caseType);
                    $("#preview").attr("src","http://img.boyitongcheng.com/" + obj.imgUrl);
                });

            },
            error : function(data){
                console.log(data);
            }
        });
    }

    $(".save").click(function () {
        var options = {
            url: '/htmlWeb/submitExample',
            type: 'post',
            success: function (data) {
                $.ajaxSetup({cache: false});
                navPills("/htmlWeb/systemCaseListHtml");
            },
            error:function () {
                $.ajaxSetup({cache: false});
                tip("上传失败");
                navPills("/htmlWeb/systemCaseListHtml");
            }
        };
        $("#form").ajaxForm(options);
    });
    $("#caseDetail").on("keyup",function () {
        if(!/^[0-9]*$/.test(this.value)){
            tip("请输入数字!");
            $(this).val("");
        }
    });
});

function cancle(){
    navPills("/htmlWeb/systemCaseListHtml");
}